package com.zego.wawaji.base.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

import com.zego.wawaji.base.data.BaseData;

import org.json.JSONObject;

/**
 * 公共配置解析类
 * Created by Su on 2017/12/23.
 */
public class Common extends BaseData implements Parcelable {
    private String InviteWwCoinZs;         // 邀请奖励币
    private String HaveRedPacket;           // 公告栏中是否有红包公告 = "1" ： 有
    private String FreeSendWwMin;           // 包邮件数
    private String RequsetSendWwCoinMin;    // 邮费价格
    private String InviteImg;               // 邀请页背景
    private String ExchangeImg;             // 商城兑换说明页

    @Override
    public void parseJson(String jsonStr) {
        JSONObject jsonObject = getJsonObject(jsonStr);

        this.InviteWwCoinZs = jsonObject.optString("InviteWwCoinZs");
        this.HaveRedPacket = jsonObject.optString("HaveRedPacket");
        this.FreeSendWwMin = jsonObject.optString("FreeSendWwMin");
        this.InviteImg = jsonObject.optString("InviteImg");
        this.RequsetSendWwCoinMin = jsonObject.optString("RequsetSendWwCoinMin");
        this.ExchangeImg = jsonObject.optString("ExchangeImg");
    }

    public String getExchangeImg() {
        return ExchangeImg;
    }

    public String getRequsetSendWwCoinMin() {
        return RequsetSendWwCoinMin;
    }

    public String getInviteImg() {
        return InviteImg;
    }

    public String getFreeSendWwMin() {
        return FreeSendWwMin;
    }

    public boolean haveRedPacket() {
        return TextUtils.equals("1", HaveRedPacket);
    }

    public String getInviteWwCoinZs() {
        return InviteWwCoinZs;
    }

    public Common() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.InviteWwCoinZs);
        dest.writeString(this.HaveRedPacket);
        dest.writeString(this.FreeSendWwMin);
        dest.writeString(this.RequsetSendWwCoinMin);
        dest.writeString(this.InviteImg);
        dest.writeString(this.ExchangeImg);
    }

    protected Common(Parcel in) {
        this.InviteWwCoinZs = in.readString();
        this.HaveRedPacket = in.readString();
        this.FreeSendWwMin = in.readString();
        this.RequsetSendWwCoinMin = in.readString();
        this.InviteImg = in.readString();
        this.ExchangeImg = in.readString();
    }

    public static final Creator<Common> CREATOR = new Creator<Common>() {
        @Override
        public Common createFromParcel(Parcel source) {
            return new Common(source);
        }

        @Override
        public Common[] newArray(int size) {
            return new Common[size];
        }
    };
}
